<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
</body>
<script>
  // 参考图片镜像服务
  // https://www.nstun.com/circle/40543.html
  const image = new Image()
  image.setAttribute('crossOrigin', 'anonymous')
  let url = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQFb8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyMmlvRDFYRHlmYkcxcElsa2h6Y28AAgTsnzNjAwSA9SAA'
  // let baseUrl = 'https://img.noobzone.ru/getimg.php?url='
  // let baseUrl = 'https://collect34.longsunhd.com/source/plugin/yzs1013_pldr/getimg.php?url='
  // let baseUrl = 'https://collect34.longsunhd.com/source/plugin/yzs1013_pldr/getimg.php?url='
  let baseUrl = 'https://images.weserv.nl/?url='
  image.src = baseUrl + url
  image.setAttribute('crossOrigin', 'anonymous')
  image.onload = () => {
    const canvas = document.createElement('canvas')
      canvas.width = image.width
      canvas.height = image.height
      const context = canvas.getContext('2d')
      context.drawImage(image, 0, 0, image.width, image.height)
      canvas.toBlob((blob) => {
        const url = URL.createObjectURL(blob)
        const a = document.createElement('a')
        a.download = name || 'photo'
        a.href = url
        a.click()
        a.remove()
        URL.revokeObjectURL(url)
      })
  }
</script>
</html>
